package com.team.controller;

import com.team.dto.TeamPageQueryDTO;
import com.team.entity.Team;
import com.team.entity.TeamDetails;
import com.team.service.TeamService;
import com.team.vo.PageResult;
import com.team.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping
@Slf4j

public class TeamController {

    @Autowired
    private TeamService teamService;


    /**
     * 分页查询团队
     * @param teamPageQueryDTO
     * @return
     */
    @GetMapping("/page")
    public Result<PageResult> page(TeamPageQueryDTO teamPageQueryDTO) {
        log.info("分页查询: {}", teamPageQueryDTO);
        PageResult pageResult = teamService.page(teamPageQueryDTO);
        return Result.success(pageResult);
    }

    /**
     * 直接查询所有团队
     * @return
     */
    @GetMapping("/getAllTeams")
    public Result<List<Team>> getAll() {
        List<Team> list=teamService.getAll();
        return Result.success(list);
    }

    /**
     * 获得某个团队详情
     * @param tid
     * @return
     */
    @GetMapping("/getTeam_details")
    public Result<TeamDetails> getTeamDetails(Integer tid){
        return Result.success(teamService.getTeamDetails(tid));
    }
}
